﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class FaqManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            get_All_Faq();
        }
    }

    public void get_All_Faq()
    {
        cpPaging.PageSize = 30;
        cpPaging.DataSource = BusLogic.Faq.get_ALL_FAQ().Tables[0].DefaultView;
        cpPaging.BindToControl = FaqRepeater;
        FaqRepeater.DataSource = cpPaging.DataSourcePaged;
        FaqRepeater.DataBind();
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in FaqRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckFaq");

            if (cb.Checked == true)
            {
                TextBox txtFaqId = (TextBox)item.FindControl("txtFaqId");
                BusLogic.Faq.remove_FAQ(int.Parse(txtFaqId.Text));
            }
        }
        get_All_Faq();
        cbxCheckALLFaq.Checked = false;
    }

    protected void cbxCheckALLFaq_CheckedChanged(object sender, EventArgs e)
    {
        if (!cbxCheckALLFaq.Checked)
        {
            foreach (RepeaterItem item in FaqRepeater.Items)
            {
                CheckBox cb = (CheckBox)item.FindControl("cbxCheckFaq");
                cb.Checked = false;
            }
        }
        else
        {
            foreach (RepeaterItem item in FaqRepeater.Items)
            {
                CheckBox cb = (CheckBox)item.FindControl("cbxCheckFaq");
                cb.Checked = true;
            }
        }
    }


}
